package com.sunlands.zlcx.usercenter.vo.feign;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import org.apache.commons.lang.time.DateFormatUtils;

import java.util.Date;

/**
 * <p></p>
 * <PRE>
 * <BR>    修改记录
 * <BR>-----------------------------------------------
 * <BR>    修改日期         修改人          修改内容
 * </PRE>
 *
 * @author zl
 * @version 1.0
 * @date Created in 2019/4/18 14:00
 * @copyright: Copyright (c) founders
 */
@Data
@ToString
@ApiModel(value="上麦信息")
public class RoomPublisherVO {

    @ApiModelProperty(value="id")
    private Long id;

    @ApiModelProperty(value="上麦申请id")
    private Long publisherRecordId;

    @ApiModelProperty(value="房间id")
    private Long roomId;

    @ApiModelProperty(value="用户id")
    private Long userId;

    @ApiModelProperty(value="用户昵称")
    private String userName;

    @ApiModelProperty(value="用户头像")
    private String userAvatarUrl;

    @ApiModelProperty(value="申请时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date applyTime;

    @ApiModelProperty(value="同意上麦时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date agreeTime;

    @ApiModelProperty(value="下麦/取消申请时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date quitTime;

    @ApiModelProperty(value="连麦状态：1-申请中，2-上麦中，3-已取消，4-已下麦，5-被强制踢出")
    private Integer publisherState;

    @ApiModelProperty(value="记录时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    @ApiModelProperty(value="修改时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    @ApiModelProperty(value="申请时间缩写")
    private String applyTimeShort;

    @ApiModelProperty(value="连麦时长（秒）")
    private Long publishedSeconds;

    public String getApplyTimeShort() {
        if(applyTime!=null){
            return DateFormatUtils.format(applyTime,"HH:mm");
        }
        return null;
    }

    public Long getPublishedSeconds() {
        if(agreeTime!=null && quitTime!=null){
            return (quitTime.getTime()-agreeTime.getTime())/1000;
        }
        return 0L;
    }

    public Long getPublisherRecordId() {
        return id;
    }
}
